package com.gragra.data.tests;
import static org.junit.Assert.*;
import java.util.Collection;
import java.util.LinkedList;
import org.junit.Before;
import org.junit.Test;
import com.gragra.structures.Structure;
import com.gragra.data.Corpus;
import com.gragra.data.CorpusBaseImplementation;
/**
 * @author Christoph Teichmann
 * @version 0.1
 */
public class TestCorpus
{
	private Corpus<Structure> c;
	/**
	 * @throws java.lang.Exception
	 */
	@Before
	public void setUp() throws Exception
	{c = new CorpusBaseImplementation<Structure>();}
	/**
	 * Test method for {@link data.Corpus#addData(structures.StructureGenerator, java.lang.Iterable)}.
	 */
	@Test
	public void testAddDataStructureGeneratorIterableOfString()
	{
		Collection<String> s = new LinkedList<String>();
		s.add("a");
		s.add("b");
		c.addData(new DummyStructureGenerator(),s);
		assertEquals(c.size(), 2,0.0);
	}
	/**
	 * Test method for {@link data.Corpus#addData(structures.StructureGenerator, java.lang.String)}.
	 */
	@Test
	public void testAddDataStructureGeneratorString()
	{
		c.addData(new DummyStructureGenerator(),"a");
		assertEquals(c.size(), 1,0.0);
	}
	/**
	 * Test method for {@link data.Corpus#addData(java.util.Collection)}.
	 */
	@Test
	public void testAddDataCollectionOfStructure()
	{
		Collection<Structure> s = new LinkedList<Structure>();
		s.add(new DummyStructureGenerator().make("a"));
		c.addData(s);
		assertEquals(c.size(), 1,0.0);
	}
	/**
	 * Test method for {@link data.Corpus#getEntry(int)}.
	 */
	@Test
	public void testGetEntry()
	{
		Structure k;
		Collection<Structure> s = new LinkedList<Structure>();
		s.add(k = new DummyStructureGenerator().make("a"));
		c.addData(s);
		assertEquals(k,c.getEntry(0));
	}
	/**
	 * Test method for {@link data.Corpus#iterator()}.
	 */
	@Test
	public void testIterator()
	{
		Structure k;
		Collection<Structure> s = new LinkedList<Structure>();
		s.add(k = new DummyStructureGenerator().make("a"));
		c.addData(s);
		assertEquals(k,c.iterator().next());
	}
}